package com.harry.hr.dao.impl;

import java.util.List;

import org.hibernate.criterion.DetachedCriteria;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.harry.hr.dao.HumanFileDAO;
import com.harry.hr.entity.HumanFile;
import com.harry.hr.entity.HumanFileDig;

public class HumanFileDAOImpl extends HibernateDaoSupport implements
		HumanFileDAO {
	
	public HumanFileDAOImpl(){
		System.out.println("=============================我被加载一次====================================");
	}

	public void addHumanFile(HumanFile humanFile) {
		this.getHibernateTemplate().save(humanFile);		
	}

	public void delHumanFile(HumanFile humanFile) {
		this.getHibernateTemplate().delete(humanFile);		
	}

	@SuppressWarnings("unchecked")
	public List<HumanFile> getAllHumanFile() {
		String hql="from HumanFile";
		return this.getHibernateTemplate().find(hql);
	}

	public HumanFile getById(int hufId) {		
		return (HumanFile)this.getHibernateTemplate().get(HumanFile.class, hufId);
	}

	public void updateHumanFile(HumanFile humanFile) {
		this.getHibernateTemplate().merge(humanFile);
		
	}

	@SuppressWarnings("unchecked")
	public List<HumanFile> getHumanFileByPropPage(DetachedCriteria criteria,
			int firstResult, int maxResults) {
		return this.getHibernateTemplate().findByCriteria(criteria, firstResult, maxResults);
	}

	public int getHumanFileByPropPageCount(DetachedCriteria criteria) {		
		return this.getHibernateTemplate().findByCriteria(criteria).size();
	}

	public void addDigHumanFile(HumanFileDig humanFileDig) {
		this.getHibernateTemplate().save(humanFileDig);		
	}


}
